nomycnf: simplify db parameters#4088
Conversation
* Introduce new db connectivity flags. * Mark old flags as deprecated. * If new flags are set, they supersede legacy flags. * Provide defaults to existing flags so one doesn't have to specify them for normal cases. Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
DBConfigs API has been changed: * Conn param members have been made private and are not changeable. * New functions like AppWithDB, etc. have been added. They return newly allocated conn params. * New DBName field can now be set by the app, which can then be combined with conn params as needed. * SideCarDBName and DBName are atomic. There's no worry about possible race while accessing them. * 'WithDB' functions return a conn with the db name set. For cases where a db is always needed, like App, the API only provides a WithDB function. Also, vice-versa. * A test has been added to tabletmanager to show that the new flags work. Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
* Remove legacy parameters from examples. * Add comments. Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
It's possible one may want to enable SSL for just the repl user because replication can happen on open networks. The per-user use_ssl flag allows you to select which connections use ssl and which don't. DBConfigs has been refactored to use a map instead of hardcoded user configs. This reduces boilerplating. Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
jvaidya
left a comment
There was a problem hiding this comment.
Looks great on the whole. This will really reduce a lot of confusion, especially once the deprecated parameters are deleted. Thanks for tackling this.
I have a couple comments inline.
go/vt/dbconfigs/dbconfigs.go
Outdated
| SidecarDBName string | ||
| // The flags will change the global singleton | ||
| // TODO(sougou): deprecate the legacy flags. | ||
| func registerUserFlags(dbc *userConfig, name string) { |
There was a problem hiding this comment.
- Rename to registerPerUserFlags?
- Rename "name" to "username"?
There was a problem hiding this comment.
I can call it key or userKey, because the actual username is a field inside the struct.
| // Check for only one. | ||
| break | ||
| } | ||
| dbConfigs.SidecarDBName.Set("_vt") |
There was a problem hiding this comment.
Use the command line parameter rather than hard-coding "_vt".
There was a problem hiding this comment.
It's the eventual intent.
The problem is that "_vt" is hard-coded all over the place. Before we can do the command-line, we need to refactor those places to use the sidecar name field.
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
jvaidya
left a comment
There was a problem hiding this comment.
Thanks for addressing the feedback. LGTM.
This is the first step towards vttablet not depending on mycnf. This PR makes the following changes:
use_sslflag has been added that lets you choose which connections must use SSL. This allows you to selectively enable SSL for certain connections. The use case for this is thereplconnection, because replication can go over open networks.db_host, etc. have now been introduced.